package com.example.finalwork.DB;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import androidx.annotation.Nullable;

public class DataBaseHelper extends SQLiteOpenHelper {
    private static final String TAG = "DataBaseHelper";
    public DataBaseHelper(@Nullable Context context) {
        super(context, Constants.DataBase_Name, null, Constants.VERSION_CODE);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //创建时的回调
        Log.d(TAG,"创建数据库...");
        //创建表格
        String sql1 = "create table User(UserName varchar(20),PassWord varchar(20));";
        String sql2 = "create table Income(in_Id integer,in_User varchar(20),in_Name varchar(20),in_Date varchar(20),in_Amount varchar(20),in_Remark varchar(20));";
        String sql3 = "create table Pay(pay_Id integer,pay_User varchar(20),pay_Name varchar(20),pay_Date varchar(20),pay_Amount varchar(20),pay_Remark varchar(20));";
        db.execSQL(sql1);
        db.execSQL(sql2);
        db.execSQL(sql3);


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //升级数据库时的回调
        Log.d(TAG,"升级数据库...");


    }
}
